﻿@model ZKEACMS.Common.Models.NavigationEntity
@{
    Script.Reqiured("validate").AtFoot();
}

<div class="panel panel-default">
    <div class="panel-heading">
        <div>导航</div>
    </div>
    <div class="panel-body">
        @using (Html.BeginForm())
        {
            @Html.EditorForModel()
            <div class="toolBar">
                @if (Authorizer.Authorize(PermissionKeys.ManageNavigation))
                {
                    <input type="submit" class="btn btn-primary" value="保存" data-value="@ActionType.Update" />
                    <input type="button" class="btn btn-warning append-html" value="转为伪静态路径" />
                    <input type="submit" class="btn btn-danger delete" value="删除" data-value="@ActionType.Delete" />
                }                
                <input type="button" class="btn btn-default cancel" value="取消" />
            </div>
        }
    </div>
</div>
@using (Script.AtFoot())
{
    <script type="text/javascript">
        $(function () {
            $(document).on("click", ".append-html", function () {
                var url = $("#Url");
                var path = url.val();
                if (!url.val()) {
                    Easy.ShowMessageBox("提示", "请先输入URL地址");
                }
                else if (path.indexOf("?") >= 0) {
                    Easy.ShowMessageBox("提示", "不支持带有参数的URL地址静态化")
                }
                else {
                    if (path.indexOf(".html") < 0) {
                        url.val(path + ".html");
                    }
                }
            }).on("click", ".delete", function () {
                return confirm("删除导航会删除对应的子导航，确定要删除吗？");
            });
        });
    </script>
}